//376
class Solution {
    public int wiggleMaxLength(int[] nums) {
        int len = nums.length;
        if (len == 1) {
            return 1;
        }
        int[] dp1 = new int[len];
        int[] dp2 = new int[len];
        dp1[0] = 1;
        for (int i = 1; i < len; i++) {
            dp1[i] = 1;
            for (int j = 0; j < i; j++) {
                int tmp = nums[j] - nums[i];
                if (dp2[j] == 0 && nums[j] != nums[i]) {
                    if (dp1[j]+1 > dp1[i]) {
                        dp1[i] = dp1[j]+1;
                        dp2[i] = tmp;
                    }
                }
                else {
                    if (tmp * dp2[j] < 0) {
                        if (dp1[j]+1 > dp1[i]) {
                            dp1[i] = dp1[j]+1;
                            dp2[i] = tmp;
                        }
                    }
                }
            }
        }
        int max = 1;
        for (int i = 1; i < len; i++) {
            max = Math.max(max, dp1[i]);
        }
        return max;
    }
}
//300
class Solution {
    public int lengthOfLIS(int[] nums) {
        int len = nums.length;
        if (len == 1) {
            return 1;
        }
        int[] dp = new int[len];
        dp[0] = 1;
        for (int i = 1; i < len; i++) {
            dp[i] = 1;
            for (int j = 0; j < i; j++) {
                if (nums[i] > nums[j]) {
                    dp[i] = Math.max(dp[j]+1, dp[i]);
                }
            }
        }
        int max = dp[0];
        for (int i = 1; i < len; i++) {
            max = Math.max(max, dp[i]);
        }
        return max;
    }
}
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        int b = in.nextInt();
        int x = in.nextInt();
        int y = in.nextInt();
        int minCount = 0;
        if (y >= x) {
            minCount = Math.max(a,b)/y;
            if (Math.max(a,b)%y != 0) {
                minCount++;
            }
        }else {
            minCount = func(a, b, x, y, 0); 
        }
        System.out.println(minCount);
    }
    
    public static int func(int a, int b, int x, int y, int count) {
        if (a <= 0 && b <= 0) {
            return count;
        }
        int a1 = Integer.MAX_VALUE;
        int a2 = Integer.MAX_VALUE;
        if (a > 0) {
           a1 = func(a-x, b, x, y, count+1); 
        }
        if (b > 0) {
            a2 = func(a, b-x, x, y, count+1);
        }
        int a3 = func(a-y, b-y, x, y, count+1);
        return Math.min(Math.min(a1,a2),a3);
    }
}






